package logger

import (
	"log"
	"time"

	"gopkg.in/natefinch/lumberjack.v2"
)

func Info(v ...any) {
	Write("info", v...)
}

func Debug(v ...any) {
	Write("debug", v...)
}

func Error(v ...any) {
	Write("error", v...)
}

func Write(level string, v ...any) {
	logFileName := time.Now().Format("2006-01-02") + "_" + level + ".log"

	logger := &lumberjack.Logger{
		Filename:   "runtime/logs/" + logFileName,
		MaxSize:    100,
		MaxBackups: 3,
		MaxAge:     28,
		LocalTime:  true,
		Compress:   true,
	}
	defer logger.Close()
	log.SetOutput(logger)
	log.Println(v...)
}
